home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / tut-code.lha / tut-code / fonts / main.c < prev   
Encoding:
C/C++ Source or Header  |  1992-01-03  |  1.2 KB  |  51 lines

  1. #include <InterViews/font.h>
  2. #include <InterViews/place.h>
  3. #include <InterViews/session.h>
  4. #include <InterViews/style.h>
  5. #include <InterViews/window.h>
  6. #include <OS/string.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. static PropertyData props[] = {
  11.     { "*family", "Times" },
  12.     { "*face", "Roman" },
  13.     { "*size", "12" },
  14.     { nil }
  15. };
  16.  
  17. static OptionDesc options[] = {
  18.     { "-family", "*family", OptionValueNext },
  19.     { "-face", "*face", OptionValueNext },
  20.     { "-size", "*size", OptionValueNext },
  21.     { nil }
  22. };
  23.  
  24. int main(int argc, char** argv) {
  25.     Session* session = new Session("Himom", argc, argv, options, props);
  26.     Style* style = session->style();
  27.  
  28.     String family;
  29.     style->find_attribute("family", family);
  30.     NullTerminatedString family_ns(family);
  31.     FontFamily* fm = new FontFamily(family_ns.string());
  32.  
  33.     String face;
  34.     style->find_attribute("face", face);
  35.  
  36.     long size;
  37.     style->find_attribute("size", size);
  38.  
  39.     const char* name;
  40.     float scale;
  41.     NullTerminatedString ns(face);
  42.     if (fm->font(int(size), ns.string(), name, scale)) {
  43.     printf("font '%s', scale %.2f\n", name, scale);
  44.     } else {
  45.     printf(
  46.         "no match for %.*s-%.*s-%d\n", family.length(), family.string(),
  47.         face.length(), face.string(), size
  48.     );
  49.     }
  50. }
  51.